<template>
  <div class="c-btn">
      <transition name="move">
        <div class="btn_min" v-show="food.count>0" @click.stop="food.count--">
          <i class="inner fa fa-minus-circle"></i>
        </div>
      </transition>
      <div class="num" v-show="food.count>0">{{food.count}}</div>
      <div class="btn_add fa fa-plus-circle" @click.stop="add($event)">
      </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import Vue from "vue"
  export default {
    created(){
    },
    mounted(){
    },
    props:{
      food:{
        type:Object,
        default:function(){
          return {}
        }
      }
    },
    data () {
      return {
      }
    },
    methods:{
      add(e){
        if(!this.food.count){
          Vue.set(this.food,"count",1);
        }else{
          this.food.count++
        }
        this.$emit("drop",e.target);
      },
    },
    computed:{

    },
    watch:{

    },
    components:{

    }
  }
</script>

<style lang="stylus" rel="stylesheet/styleus">
.c-btn
  font-size 0
  .btn_min
    display inline-block
    padding 6px
    line-height 24px
    vertical-align top
    transition all .4s linear
    opacity 1
    transform translate3d(0,0,0)
    &.move-enter,&.move-leave-to
      opacity 0
      transform translate3d(24px,0,0)
      .inner
        transform rotate(180deg)
    .inner
      line-height 24px
      font-size 24px
      color rgb(0,160,220)
      display inline-block
      transition all .4s linear
      transform rotate(0)
  .btn_add
    display inline-block
    padding 6px
    line-height 24px
    font-size 24px
    color rgb(0,160,220)
    vertical-align top
  .num
    display inline-block
    vertical-align top
    line-height 36px
    font-size 12px
    width 12px
    text-align center
    color: rgb(147,153,159)
</style>
